home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan
/
Opus 5 - Magellan.iso
/
Extras
/
Install_3.3
/
ARexx
/
Install_Request.dopus5
< prev
next >
Wrap
Text File
|
1997-05-09
|
7KB
|
255 lines
/* $VER: Install_Request.dopus5 3.1 (09.05.97) © Frédéric Steinfels
*/
signal on BREAK_C
signal on BREAK_D
signal on BREAK_E
signal on BREAK_F
signal on HALT
signal on IOERR
signal on SYNTAX
signal on FAILURE
options failat 21
options results
parse arg arguments
ProgramName = "Install_Request.dopus5";
ArgsTemplate = "PORT/A,MNPORT/A,EXPORT/A,MYPORT/A,MYID/A,SRCP/A,DSTP/A"
lf='0a'x
if strip(arguments) = '?' then do
Call WriteCh(STDOUT, ArgsTemplate || ': ')
pull arguments
end; else nop
if ~ReadArgs(arguments,ArgsTemplate) then do
say Fault(RC,ProgramName)
exit 10
end; else nop
drop arguments
catalog=opencatalog('Install.dopus5.catalog','english',0)
address value PORT
inlocpr='DOpus5:System/Install_Locale.prefs'
if ~open(lp,inlocpr,'READ') then do
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(15,'Unable to open') inlocpr || '"' GetCatStr(0,'Abort')
Call CleanUP
exit
end
junk=readln(lp)
month=1
do while month < 13
cnt=0
do while cnt<9
d.month.cnt=readln(lp)
cnt=cnt+1
end
month=month+1
end
d.tr=readln(lp)
Call Close(lp)
MYPORTH=openport(MYPORT)
do until CMD='0'
call waitpkt(MYPORT)
Packet=getpkt(MYPORT)
if Packet ~= null() then do
ln = getarg(Packet,0)
ID=substr(ln,1,1)
CMD=substr(ln,2,1)
ARG=substr(ln,3)
call CheckArg
IF ID=0 & CMD>0 THEN DO
parse var arg path '0a'x name '0a'x fdate.1 '0a'x fdate.2 '0a'x vdate.1 '0a'x vdate.2 '0a'x size.1 '0a'x size.2 '0a'x base.1 '0a'x base.2 '0a'x ver.1 '0a'x ver.2 '0a'x rev.1 '0a'x rev.2 '0a'x info.1 '0a'x info.2 '0a'x com.1 '0a'x com.2 '0a'x ps
req=''
if path~='' then req=path || lf
req=req || name || lf || lf
cnt=1
do while cnt<3
if cnt=1 then req=req || GetCatStr(59,'Source') || ':' srcp || lf
if cnt=2 then req=req || lf || GetCatStr(60,'Destination') || ':' dstp || lf
req=req || size.cnt 'bytes' || ','
t=fdate.cnt
call GetTime
req=req hours || ':' || mins || ':' || secs || ',' dt || lf
if base.cnt~='' then req=req base.cnt
if ver.cnt~=0 | rev.cnt~=0 then req=req ver.cnt || '.' || rev.cnt
if vdate.cnt~=0 then do
days=vdate.cnt
Call GetDate
req = req '(' || dt || ')'
end
if base.cnt~='' | ver.cnt~=0 | rev.cnt~=0 | vdate.cnt~=0 then req=req || lf
if info.cnt ~= '' then req=req || info.cnt || lf
if com.cnt ~= '' then req=req || com.cnt || lf
cnt=cnt+1
end
req=left(req,length(req)-1)
addlf=lf
IF CMD~=5 & CMD~=7 THEN DO
IF CMD=1 | CMD=6 THEN DO
req=req || addlf || lf || GetCatStr(63,'Warning: Destination file is delete protected!')
addlf=''
end
else do
prot=statef(makepath(makepath(dstp,path),name))
parse var prot . ' ' . ' ' . ' ' prot ' ' .
if RIGHT(prot,1)='-' then do
req=req || addlf || lf || GetCatStr(63,'Warning: Destination file is delete protected!')
addlf=''
if CMD=2 then CMD=8
if CMD=3 then CMD=1
end
end
end
IF CMD~=4 & CMD~=6 THEN DO
IF CMD=2 | CMD=7 THEN DO
req=req || addlf || lf || GetCatStr(62,'Warning: Source file is delete protected!')
addlf=''
end
else do
prot=statef(makepath(makepath(srcp,path),name))
parse var prot . ' ' . ' ' . ' ' prot ' ' .
if RIGHT(prot,1)='-' then do
req=req || addlf || lf || GetCatStr(63,'Warning: Source file is delete protected!')
addlf=''
if CMD=1 then CMD=8
if CMD=3 then CMD=2
end
end
end
if CMD>0 & CMD<9 then do
if CMD=1 | CMD=2 | CMD=3 | CMD=8 then do
dopus request '"' || req || '"' GetCatStr(53,'repl Dest') || '|' || GetCatStr(54,'repl Source') || '|' || GetCatStr(55,'skip')
answ=rc
end
if CMD=4 | CMD=6 then do
dopus request '"' || req || '"' GetCatStr(53,'repl Dest') || '|' || GetCatStr(55,'skip')
answ=rc
end
if CMD=5 | CMD=7 then do
dopus request '"' || req || '"' GetCatStr(54,'repl Source') || '|' || GetCatStr(55,'skip')
answ=rc
if answ=1 then answ=2
end
if answ=0 then answ=3
if answ=1 then do
if CMD=6 | CMD=1 | CMD=8 then do
command wait protect '"' || makepath(makepath(dstp,path),name) || '"' SET D
end
dopus send EXPORT MYID || answ || path || lf || name
end
if answ=2 then do
if CMD=7 | CMD=2 | CMD=8 then do
command wait protect '"' || makepath(makepath(srcp,path),name) || '"' SET D
end
dopus send EXPORT MYID || answ || path || lf || name
end
dopus send MNPORT MYID || answ || ps
end
end
end
end
Call CleanUP
exit
GetTime:
days=t % 86400
t=t // 86400
hours=t % 3600
t=t // 3600
mins=t % 60
t=t // 60
secs=t
hours=copies('0',2-length(hours)) || hours
mins=copies('0',2-length(mins)) || mins
secs=copies('0',2-length(secs)) || secs
Call GetDate
return
GetDate:
dt=date('s',days,'i')
year=substr(dt,1,4)
month=substr(dt,5,2)
if left(month,1)='0' then month=substr(month,2)
day=substr(dt,7,2)
dt=copies(' ',d.month.0)
dt=overlay(d.tr,dt,d.month.1)
dt=overlay(d.tr,dt,d.month.2)
dt=overlay(d.month.8,dt,d.month.6)
dt=overlay(day,dt,d.month.3)
dt=overlay(substr(year,3),dt,d.month.4)
if d.month.5~=0 then do
dt=overlay(left(year,2),dt,d.month.5)
end
return
CheckArg:
IF DATATYPE(ID)~='NUM' | DATATYPE(CMD)~='NUM' THEN Call CheckArgFail
IF ID~=0 THEN Call CheckArgFail
IF CMD>5 THEN Call CheckArgFail
RETURN
CheckArgFail:
address value PORT
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || GetCatStr(52,'Invalid packet received') || lf || 'ID=' || ID || lf || 'CMD=' || CMD || lf || 'ARG=' || ARG || '"' GetCatStr(0,'Abort')
Call CleanUP
exit
ERROR:
HALT:
IOERR:
SYNTAX:
IF RC ~= 0 THEN DO
line=sigl
text=errortext(rc)
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || lf || text || lf || GetCatStr(19,'Line') line || '"' GetCatStr(0,'Abort')
END
else do
dopus request '"' || GetCatStr(18,'Error in') ProgramName || lf || GetCatStr(61,'Port') MYPORT || '"' GetCatStr(0,'Abort')
end
BREAK_C:
BREAK_D:
BREAK_E:
BREAK_F:
Call CleanUP
exit
CleanUp:
dopus send MNPORT MYID || 0
if POS(MYPORT,SHOW('p'))~=0 then do
Call FORBID()
Call ClosePort(MYPORTH)
Call PERMIT()
end
Call CloseCatalog(catalog)
return
getcatstr: /* Thank you for this procedure, Edmund */
parse arg msgno,msgstring
if catalog~=0 then
msgstring=getcatalogstr(catalog,msgno,msgstring)
do i=3 to arg()
parse var msgstring fore '%s' aft
msgstring=fore||arg(i)||aft
end
return msgstring